package com.wowotou.rabbitmq.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class PriorityQueueConfig {
    public static final String PRIORITY_QUEUE = "priority.queue";
    @Bean("priorityQueue")
    public Queue priorityQueue(){
        return QueueBuilder
                       .durable(PRIORITY_QUEUE)
                       .maxPriority(10)
                       .build();
    }

    @Bean("priorityQueueBinding")
    public Binding priorityQueueBinding(@Qualifier("priorityQueue")Queue priorityQueue,@Qualifier("xExchange") DirectExchange exchange){
        return BindingBuilder.bind(priorityQueue).to(exchange).with("priorityKey");
    }
}
